// 解构赋值
/* let arr = [1,2,3];
let a = arr[0];
let b = arr[1];
let c = arr[2];
console.log(a,b,c); */
let [a,b,c]  = [1,2,3]; // 数组的结构赋值
console.log(a,b,c);

// 对象的解构赋值 :可以起个别名 =表示默认值
let {name:userName,sex,age=18}  = {name: "along",sex:"M",age:30};
console.log(userName,age);

let [[,,num3],str,{city}] = [[2,4,6],"hello",{city:"beijing",address:"北三环"}];
console.log(num3);
console.log(str);
console.log(city);

// 解构应用
function ajax({url=new Error(),method="get",data={}}) {
   console.log(method);
}

ajax({
    url:"",
    method: "post"
});